<?php include_component('tree'
                    , 'path'
                    , array('path' => 'friends'
                        , 'label' => 'PARTNERS')); ?>
<br/>
<div class="text">
    <?php /* @var $partner Partner */ ?>
    <h2><?php echo ucfirst(Tree::getNameForPathByLabel('PARTNERS', 'friends')); ?></h2>
    <br />
    <?php $city_id = ''?>
    <?php if($pager->getNbResults() > 0): ?>
    <table class="" cellpadding="4" cellspacing="2">
        <?php $i = 1; foreach($pager->getResults() as $partner ): $odd = fmod(++$i, 2) ?>
            <?php if($city_id == $partner->getGeoNameId()): ?>
                <?php $city_view = ''; ?>
    		<?php else: ?>
    			<?php $city_view = $partner->getGeoName(); ?>
            <?php endif; ?>
    		
        <tr class="sf_admin_row_<?php echo $odd ?>">
            <td align="left" valign="top">
            <?php if(has_any_role_id(array(MyConstants::ROLE_ADMIN, MyConstants::ROLE_MODERATOR))): ?>
                <?php echo link_to(image_tag('pencil.png')
                                , 'partners/edit?id=' . $partner->getId());?>
            <?php endif; ?>
                <?php if( $partner->getFilePath() ): ?>
                    <?php echo link_to(
                                        image_tag(
                                            '/uploads/partners/' . $partner->getFilePath()
                                            , array(
                                                'border' => '0'
                                                , 'alt' => $partner->getName()
                                                , 'title' => $partner->getName()
                                            )
                                        )
                                        , $partner->getLinkTo()
                                    ); ?>
                <?php endif; ?>
            </td>
            <td width="50%" align="left" valign="top">
                <?php if( $partner->getLinkTo() ): ?>
                    <?php echo link_to(
                                    $partner->getName()
                                    , $partner->getLinkTo()
                                    , array(
                                        'class' => 'registration'
                                    )
                                ); ?>
                <?php else: ?>
                    <?php echo $partner->getName() ?>
                <?php endif; ?>
            </td>
            <td width="20%" align="left" valign="top"><?php echo $city_view ?></td>
        </tr>
    
    		<?php $city_id = $partner->getGeoNameId()?>
        <?php endforeach; ?>
    </table>
    <?php else: ?>
        <?php echo __('no result'); ?>
    <?php endif; ?>
    
    <?php if ($pager->haveToPaginate()): ?>
        <div class="paging">
            <div class="paging_link">
                <?php echo link_to(
                        '&laquo;'
                        , 'partners/index?page='.$pager->getFirstPage()
                    ) ?>
            </div>
            <div class="paging_link">
                 <?php echo link_to(
                        '&lsaquo;'
                        , 'partners/index?page='.$pager->getPreviousPage()
                    ) ?>
            </div>
                <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
                <?php echo ($page == $pager->getPage()) ? '<div class="paging_current">' . $page . '</div>' : '<div class="paging_link">' . link_to($page, 'partners/index?page='.$page) . '</div>' ?>
                <?php if ($page != $pager->getCurrentMaxLink()): ?>
                <?php endif; ?>
                <?php endforeach; ?>
            <div class="paging_link">
                <?php echo link_to(
                            '&rsaquo;'
                            , 'partners/index?page='.$pager->getNextPage()
                        ) ?>
            </div>
            <div class="paging_link">
                <?php echo link_to(
                            '&raquo;'
                            , 'partners/index?page='.$pager->getLastPage()
                        ) ?>
            </div>
        </div>
    <?php endif; ?>
</div>
<div class="dashed_line">
</div>
<br/>